﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SolicitarTutoria.aspx.cs"
    Inherits="Ent.Inscripcion.Presentacion.SolicitarTutoria" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register Src="wucVerificaPago.ascx" TagName="wucVerificaPago" TagPrefix="Ent" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Solicitar Tutoría</title>
    <ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="Script" />
    <script type="text/javascript" src="Resources/Js/EntInscripcion.js"></script>
</head>
<body>
    <ext:ResourceManager ID="ResourceManager1" runat="server" Locale="es" />
    <ext:Hidden ID="hidIdSolicitud" runat="server"/>
    <ext:Hidden ID="hidIdTutoria" runat="server"/>
    <ext:Hidden ID="hidAccionSolicitud" runat="server"/>
    <ext:Hidden ID="hidHI" runat="server"/>
    <ext:Hidden ID="hidHF" runat="server"/>
    <ext:Hidden ID="hidDia" runat="server"/>
    <ext:Hidden ID="hidNivel" runat="server"/>
    <ext:Hidden ID="hidAula" runat="server"/>
    <ext:Viewport ID="ViewPort1" runat="server" Layout="Fit">
        <LayoutConfig>
            <ext:VBoxLayoutConfig Align="Stretch" />
        </LayoutConfig>
        <Items>
            <ext:GridPanel ID="gdpSolTutorias" runat="server" StripeRows="true" AutoWidth="true"
                Height="600">
                <Store>
                    <ext:Store runat="server" ID="stoSolTutorias">
                        <Reader>
                            <ext:JsonReader IDProperty="Id">
                                <Fields>
                                    <ext:RecordField Name="Id" />
                                    <ext:RecordField Name="Nivel" />
                                    <ext:RecordField Name="Dia" />
                                    <ext:RecordField Name="Paralelo" />
                                    <ext:RecordField Name="Aula" />
                                    <ext:RecordField Name="Fecha" Type="Date" />
                                    <ext:RecordField Name="Hora" Type="Date" />
                                    <ext:RecordField Name="Docente" />
                                    <ext:RecordField Name="Estado" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <TopBar>
                    <ext:Toolbar ID="Toolbar3" runat="server">
                        <Items>
                            <ext:Button ID="btnCrearTutoria" runat="server" Text="Registrarse para Tutoria" Icon="ReportEdit">
                                <DirectEvents>
                                    <Click OnEvent="btnCrearTutoria_Click" Failure="ManejarError();" >
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel ID="ColumnModel3" runat="server">
                    <Columns>
                        <ext:CommandColumn Width="120">
                            <Commands>
                                <ext:GridCommand CommandName="Editar" Text="Editar" Icon="PageEdit" ToolTip-Text="Editar Docente">
                                </ext:GridCommand>
                            </Commands>
                        </ext:CommandColumn>
                        <ext:Column Header="Nivel" Width="150" Sortable="true" DataIndex="Nivel">
                        </ext:Column>
                        <ext:Column Header="Aula" Width="80" Sortable="true" DataIndex="Aula" />
                        <ext:Column Header="Dia" Width="100" Sortable="true" DataIndex="Dia" />
                        <ext:Column Header="Paralelo" Width="80" Sortable="true" DataIndex="Paralelo" />
                        <ext:DateColumn Header="Hora Inicio" Width="100" Sortable="true" DataIndex="Hora"
                            Format="H:mm">
                        </ext:DateColumn>
                        <ext:Column Header="Docente" Width="200" Sortable="true" DataIndex="Docente" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel3" runat="server" SingleSelect="true">
                    </ext:RowSelectionModel>
                </SelectionModel>
                <DirectEvents>
                    <Command OnEvent="gdpSolTutorias_Command" Success="mensajeEditar(response, result, el, type, action, extraParams);"
                        Failure="ManejarError();">
                        <ExtraParams>
                            <ext:Parameter Name="Id" Value="record.data.Id" Mode="Raw" />
                        </ExtraParams>
                    </Command>
                </DirectEvents>
                <LoadMask Msg="Cargando Datos" ShowMask="true" />
            </ext:GridPanel>
        </Items>
    </ext:Viewport>
    <ext:Window ID="winSolTutorias" runat="server" Icon="Application" Title="Registro de Tutoria"
        Modal="True" AutoHeight="true" Width="650" Y="5" CenterOnLoad="true" Hidden="true"
        ButtonAlign="Center" Padding="8" Resizable="false">
        <Items>
            <ext:FieldSet runat="server" Title="Buscar horario de Tutoria" Width="620">
                <Items>
                    <ext:Panel ID="Panel3" BodyStyle="background-color:transparent;" Padding="5" Border="false"
                        runat="server" ButtonAlign="Center">
                        <Items>
                            <ext:FormPanel ID="frpDatosBusqueda" runat="server" BodyStyle="background-color:transparent;"
                                Border="false" Layout="Column" LabelWidth="50" ButtonAlign="Center">
                                <Items>
                                    <ext:Panel ID="Panel4" BodyStyle="background-color:transparent;" runat="server" ColumnWidth="0.5"
                                        Height="25" Border="false" Layout="Form">
                                        <Items>
                                            <ext:ComboBox ID="cbxNivelB" runat="server" Editable="false" DisplayField="Nombre"
                                                ValueField="Id" FieldLabel="Nivel" Mode="Local" AnchorHorizontal="95%" EmptyText="Seleccione..">
                                                <Store>
                                                    <ext:Store runat="server" ID="stoNiveles">
                                                        <Reader>
                                                            <ext:JsonReader IDProperty="Id">
                                                                <Fields>
                                                                    <ext:RecordField Name="Id" />
                                                                    <ext:RecordField Name="Codigo" />
                                                                    <ext:RecordField Name="Nombre" />
                                                                    <ext:RecordField Name="Descripcion" />
                                                                </Fields>
                                                            </ext:JsonReader>
                                                        </Reader>
                                                    </ext:Store>
                                                </Store>
                                                <ToolTips>
                                                    <ext:ToolTip ID="ToolTip3" runat="server" Title="Nivel de inglés">
                                                    </ext:ToolTip>
                                                </ToolTips>
                                            </ext:ComboBox>
                                        </Items>
                                    </ext:Panel>
                                    <ext:Panel ID="Panel6" BodyStyle="background-color:transparent;" runat="server" ColumnWidth="0.5"
                                        Border="false" Layout="Form">
                                        <Items>
                                            <ext:ComboBox ID="cbxDiaB" runat="server" AnchorHorizontal="95%" Editable="false"
                                                DisplayField="Nombre" ValueField="Id" FieldLabel="Día" Mode="Local">
                                                <Store>
                                                    <ext:Store runat="server" ID="stoDias">
                                                        <Reader>
                                                            <ext:JsonReader IDProperty="Id">
                                                                <Fields>
                                                                    <ext:RecordField Name="Id" />
                                                                    <ext:RecordField Name="Codigo" />
                                                                    <ext:RecordField Name="Nombre" />
                                                                    <ext:RecordField Name="Descripcion" />
                                                                </Fields>
                                                            </ext:JsonReader>
                                                        </Reader>
                                                    </ext:Store>
                                                </Store>
                                                <ToolTips>
                                                    <ext:ToolTip ID="ToolTip4" runat="server" Title="Día">
                                                    </ext:ToolTip>
                                                </ToolTips>
                                            </ext:ComboBox>
                                        </Items>
                                    </ext:Panel>
                                </Items>
                            </ext:FormPanel>
                        </Items>
                        <Buttons>
                            <ext:Button ID="btnBuscar" runat="server" Text="Buscar">
                                <DirectEvents>
                                    <Click Before="#{stoTutorias}.removeAll();LimpiarSeleccion();" OnEvent="btnBuscar_Click">
                                        <ExtraParams>
                                            <ext:Parameter Name="Nivel" Value="#{cbxNivelB}.getValue()" Mode="Raw">
                                            </ext:Parameter>
                                            <ext:Parameter Name="Dia" Value="#{cbxDiaB}.getValue()" Mode="Raw">
                                            </ext:Parameter>
                                        </ExtraParams>
                                        <EventMask Msg="Buscando horario de Tutorias" ShowMask="true" />
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                        </Buttons>
                    </ext:Panel>
                    <ext:GridPanel ID="gdpTutorias" runat="server" StripeRows="true" AutoWidth="true"
                        Height="150">
                        <Store>
                            <ext:Store runat="server" ID="stoTutorias">
                                <Reader>
                                    <ext:JsonReader IDProperty="Id">
                                        <Fields>
                                            <ext:RecordField Name="Id" />
                                            <ext:RecordField Name="Nivel" />
                                            <ext:RecordField Name="Dia" />
                                            <ext:RecordField Name="Paralelo" />
                                            <ext:RecordField Name="Aula" />
                                            <ext:RecordField Name="HoraInicio" Type="Date" />
                                            <ext:RecordField Name="HoraFin" Type="Date" />
                                            <ext:RecordField Name="Docente" />
                                            <ext:RecordField Name="Estado" />
                                            <ext:RecordField Name="Cupo" />
                                        </Fields>
                                    </ext:JsonReader>
                                </Reader>
                            </ext:Store>
                        </Store>
                        <ColumnModel ID="ColumnModel1" runat="server">
                            <Columns>
                                <ext:CommandColumn Width="80" Header="Acción">
                                    <Commands>
                                        <ext:GridCommand CommandName="Seleccionar" Text="Seleccionar" Icon="ArrowRight" ToolTip-Text="Seleccionar Tutoria">
                                        </ext:GridCommand>
                                    </Commands>
                                </ext:CommandColumn>
                                <ext:Column Header="Nivel" Width="70" Sortable="true" DataIndex="Nivel">
                                </ext:Column>
                                <ext:Column Header="Aula" Width="70" Sortable="true" DataIndex="Aula" />
                                <ext:Column Header="Dia" Width="70" Sortable="true" DataIndex="Dia" />
                                <ext:Column Header="Paralelo" Width="65" Sortable="true" DataIndex="Paralelo" />
                                <ext:DateColumn Header="Hora Inicio" Width="65" Sortable="true" DataIndex="HoraInicio"
                                    Format="H:mm">
                                </ext:DateColumn>
                                <ext:DateColumn Header="Hora Fin" Width="65" Sortable="true" DataIndex="HoraFin"
                                    Format="H:mm">
                                </ext:DateColumn>
                                <ext:Column Header="Docente" Width="150" Sortable="true" DataIndex="Docente" />
                                <%--<ext:Column Header="Cupo" Width="100" Sortable="true" DataIndex="Cupo">
                        </ext:Column>--%>
                                <ext:CheckColumn Header="Activo" Width="60" Sortable="true" DataIndex="Estado">
                                </ext:CheckColumn>
                            </Columns>
                        </ColumnModel>
                        <DirectEvents>
                            <Command OnEvent="ManejarAccion" Success="mensaje(response, result, el, type, action, extraParams);"
                                Failure="ManejarError();">
                                <ExtraParams>
                                    <ext:Parameter Name="Comando" Value="command" Mode="Raw" Encode="false" />
                                    <ext:Parameter Name="Id" Value="record.data.Id" Mode="Raw" />
                                    <ext:Parameter Name="Paralelo" Value="record.data.Paralelo" Mode="Raw" />
                                    <ext:Parameter Name="Aula" Value="record.data.Aula" Mode="Raw" />
                                    <ext:Parameter Name="Nivel" Value="record.data.Nivel" Mode="Raw" />
                                    <ext:Parameter Name="Dia" Value="record.data.Dia" Mode="Raw" />
                                    <ext:Parameter Name="HoraInicio" Value="record.data.HoraInicio" Mode="Raw" />
                                    <ext:Parameter Name="HoraFin" Value="record.data.HoraFin" Mode="Raw" />
                                </ExtraParams>
                            </Command>
                        </DirectEvents>
                        <SelectionModel>
                            <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
                            </ext:RowSelectionModel>
                        </SelectionModel>
                        <LoadMask Msg="Cargando Datos" ShowMask="true" />
                    </ext:GridPanel>
                </Items>
            </ext:FieldSet>
            <ext:FieldSet ID="FieldSet1" runat="server" Title="Datos del horario seleccionado"
                Width="620">
                <Items>
                    <ext:FormPanel ID="frpSolicitarTutoria" runat="server" Padding="5" Height="90" ButtonAlign="Center"
                        Layout="Column" Hidden="false" AnimCollapse="true">
                        <Items>
                            <ext:Panel ID="Panel1" runat="server" Border="false" Header="false" ColumnWidth=".5"
                                LabelWidth="80" Layout="Form">
                                <Defaults>
                                    <ext:Parameter Name="ReadOnly" Value="true" Mode="Raw">
                                    </ext:Parameter>
                                </Defaults>
                                <Items>
                                    <ext:ComboBox ID="cbxDiaS" StoreID="stoDias" runat="server" AnchorHorizontal="95%"
                                        Editable="false" DisplayField="Nombre" ValueField="Id" FieldLabel="Día" Mode="Local">
                                        <ToolTips>
                                            <ext:ToolTip ID="ToolTip5" runat="server" Title="Día del exámen">
                                            </ext:ToolTip>
                                        </ToolTips>
                                    </ext:ComboBox>
                                    <ext:TextField runat="server" ID="txtParalelo" FieldLabel="Paralelo" AnchorHorizontal="95%">
                                    </ext:TextField>
                                    <ext:TimeField ID="tfHoraInicio" FieldLabel="Hora Inicio" runat="server" MinTime="7:00"
                                        MaxTime="21:00" Increment="15" Format="H:mm" AnchorHorizontal="95%">
                                        <ToolTips>
                                            <ext:ToolTip ID="ToolTip2" runat="server" Title="Hora de inicio del exámen">
                                            </ext:ToolTip>
                                        </ToolTips>
                                    </ext:TimeField>
                                </Items>
                            </ext:Panel>
                            <ext:Panel ID="Panel2" runat="server" Border="false" Layout="Form" ColumnWidth=".5"
                                LabelWidth="80">
                                <Defaults>
                                    <ext:Parameter Name="ReadOnly" Value="true" Mode="Raw">
                                    </ext:Parameter>
                                </Defaults>
                                <Items>
                                    <ext:ComboBox ID="cbxNivelS" runat="server" Editable="false" DisplayField="Nombre"
                                        StoreID="stoNiveles" ValueField="Id" FieldLabel="Nivel" Mode="Local" AnchorHorizontal="95%">
                                        <ToolTips>
                                            <ext:ToolTip ID="ToolTip1" runat="server" Title="Nivel de inglés" AnchorHorizontal="95%">
                                            </ext:ToolTip>
                                        </ToolTips>
                                    </ext:ComboBox>
                                    <ext:TextField runat="server" ID="txtAula" FieldLabel="Aula" AnchorHorizontal="95%">
                                    </ext:TextField>
                                    <ext:TimeField ID="tfHoraFin" FieldLabel="Hora Fin" runat="server" MinTime="7:00"
                                        MaxTime="21:00" Increment="15" Format="H:mm" AnchorHorizontal="95%">
                                        <ToolTips>
                                            <ext:ToolTip ID="ToolTip6" runat="server" Title="Hora de finalización del exámen">
                                            </ext:ToolTip>
                                        </ToolTips>
                                    </ext:TimeField>
                                </Items>
                            </ext:Panel>
                        </Items>
                    </ext:FormPanel>
                </Items>
            </ext:FieldSet>
        </Items>
        <Buttons>
            <ext:Button runat="server" ID="btnGuardar" Text="Guardar" Icon="Add" Disabled="true">
                <DirectEvents>
                    <Click Before="return ValidarFormulario(#{frpSolicitarTutoria});" OnEvent="btnGuardar_Click"
                        Failure="ManejarError();" Success="LimpiarForm();#{winSolTutorias}.hide();MostrarMensaje(3,'La solicitud de Tutoria se guardo correctamente');">
                        <EventMask ShowMask="true" Msg="Guardando datos" />
                        <ExtraParams>
                            <ext:Parameter Name="Id" Value="#{hidIdSolicitud}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="Accion" Value="#{hidAccionSolicitud}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="IdHorario" Value="#{hidIdTutoria}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="Fecha" Value="#{cbxDiaB}.getValue()" Mode="Raw" />
                                    <ext:Parameter Name="Aula" Value="#{hidAula}.getValue()" Mode="Raw" />
                                    <ext:Parameter Name="Nivel" Value="#{hidNivel}.getValue()" Mode="Raw" />
                                    <ext:Parameter Name="Dia" Value="#{hidDia}.getValue()" Mode="Raw" />
                                    <ext:Parameter Name="HoraInicio" Value="#{hidHI}.getValue()" Mode="Raw" />
                                    <ext:Parameter Name="HoraFin" Value="#{hidHF}.getValue()" Mode="Raw" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:Button runat="server" ID="btnCancelar" Text="Cancelar" Icon="Stop">
                <Listeners>
                    <Click Handler="LimpiarForm();#{winSolTutorias}.hide();" />
                </Listeners>
            </ext:Button>
        </Buttons>
    </ext:Window>
    <ext:XScript ID="XScript1" runat="server">

    <script type="text/javascript">
        var LimpiarForm = function () { 
            #{frpSolicitarTutoria}.getForm().reset();
            #{btnGuardar}.setDisabled(true);
        };
        var LimpiarSeleccion = function(){
            #{btnGuardar}.setDisabled(true);
            #{frpSolicitarTutoria}.getForm().reset();
        };
        var mensaje =  function(response, result, el, type, action, extraParams){            
            if(result.extraParamsResponse.ErrorCupo=='1')
            {                
                MostrarMensaje(2,'No existe cupo para el horario seleccionado');
                LimpiarSeleccion();
            }
            else
            {
                #{btnGuardar}.setDisabled(false);
            }
        };
        var mensajeEditar =  function(response, result, el, type, action, extraParams){
            if(result.extraParamsResponse.Opcion=='0')
                MostrarMensaje(2,result.extraParamsResponse.Mensaje);
            else
                #{winSolTutorias}.show();
        };
        var MostrarRegistroSolicitud=function(){
            LimpiarForm();
            #{winSolTutorias}.show();
            #{hidAccionSolicitud}.setValue('Nuevo');
        };
    </script>
    </ext:XScript>
    <Ent:wucVerificaPago runat="server" ID="controlVerificaPago" />
</body>
</html>
